#include "qtreewidgethost.h"

#include "qtreewidgetex.h"

#include "../../libs/shared/property/qabstractproperty.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/qhostfactory.h"

QTreeWidgetHost::QTreeWidgetHost(QAbstractHost *parent):
    QAbstractItemViewHost(parent)
{
    setProperty("edit_property","treeData");
}

void QTreeWidgetHost::init_property()
{
    QAbstractItemViewHost::init_property();

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("TreeIndex");
    if(pro!=NULL)
    {
        pro->set_property("name","treeData");
        pro->set_attribute("show_name",tr("Tree Data"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","animated");
        pro->set_attribute("show_name",tr("Animated"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","rootIsDecorated");
        pro->set_attribute("show_name",tr("Root Is Decorated"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","headerHidden");
        pro->set_attribute("show_name",tr("Header Hidden"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","indentation");
        pro->set_attribute("show_name",tr("Indentation"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }
}

void QTreeWidgetHost::setAnimated(bool animated)
{
    set_property_value("animated",animated);
}

bool QTreeWidgetHost::animated()
{
    return get_property_value("animated").toBool();
}

void QTreeWidgetHost::setRootIsDecorated(bool rootIsDecorated)
{
    set_property_value("rootIsDecorated",rootIsDecorated);
}

bool QTreeWidgetHost::rootIsDecorated()
{
    return get_property_value("rootIsDecorated").toBool();
}

void QTreeWidgetHost::setHeaderHidden(bool headerHidden)
{
    set_property_value("headerHidden",headerHidden);
}

bool QTreeWidgetHost::headerHidden()
{
    return get_property_value("headerHidden").toBool();
}

void QTreeWidgetHost::setIndentation(int indentation)
{
    set_property_value("indentation",indentation);
}

int QTreeWidgetHost::indentation()
{
    return get_property_value("indentation").toInt();
}

void QTreeWidgetHost::setColumnCount(int columnCount)
{
    set_property_value("columnCount",columnCount);
}

int QTreeWidgetHost::columnCount()
{
    return get_property_value("columnCount").toInt();
}

QString QTreeWidgetHost::get_show_name()
{
    return tr("Tree View");
}

QString QTreeWidgetHost::get_show_group()
{
    return tr("Item Widgets");
}

QString QTreeWidgetHost::get_show_icon()
{
    return ":/images/listview.png";
}

void QTreeWidgetHost::create_object()
{
    m_object=new QTreeWidgetEx;
    m_object->setObjectName("treeWidget");
}

qRegisterHost("item.tree",QTreeWidgetHost,7000)
